<%@page import="com.wanmait.hotelManage.vo.Userinfo"%>
<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@page import="com.wanmait.hotelManage.vo.HotelComment"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    String path=request.getContextPath();
    List<HotelComment>hotelComments=(List<HotelComment>)request.getAttribute("hotelComments");
    
    %>
    <% Userinfo userinfo=(Userinfo)session.getAttribute("userinfo"); %>
<!DOCTYPE html>
    <script src="<%=request.getContextPath() %>/static/js/jquery-3.5.1.min.js"></script>
<jsp:include page="/inc/header.jsp"/>
    <!--End Sticky Header-->
    <!-- main header area end -->

     <!--Page Title-->
    <section class="page-title text-center">
        <div class="auto-container">
            <div class="content-box">
                <div class="title">酒店评价</div>
                <ul class="bread-crumb">
                    <li><a href="<%=path %>">首页<i class="fa fa-angle-right"></i></a></li>
                    <li>酒店评价</li>
                </ul>
            </div>
        </div>
    </section>
    <!--End Page Title-->

    <!-- testimonials-page section -->
    <section class="testimonials-section testimonials-page">
    	<div class="container">
    		<div class="roww">
    		 <%
    		if(hotelComments!=null){
    			for(int i=0;i<hotelComments.size();i++){
    				HotelComment hotelComment=hotelComments.get(i);
    				%>
    		
    			<div class="col-md-4 col-sm-6 col-xs-12">
    				<div class="single-item">
	    				<div style="height: 210px;"  class="text">
	    				<%=hotelComment.getContent() %>
	    				</div>
	    				<div class="testimonial-autor">
	    					<div class="img-box">
	    						<figure><img width="70px" height="70px" style="border-radius: 35px;" src="static/images/touxiang/<%=hotelComment.getUserinfo().getPic() %>" alt=""></figure>
	    					</div>
	    					<div class="autor-content">
	    						<h4><%=hotelComment.getUserinfo().getUsername() %></h4>
	    						<!-- <span>Happy Client</span> -->
	    					</div>
	    				</div>
	    			</div>
    			</div>
    			
    				<%
    			}
    		}
    		%> 
    			
    			<!--  <div class="col-md-4 col-sm-6 col-xs-12">
    				<div class="single-item">
	    				<div style="height: 210px;" class="text">
	    					uis aute irure dolor in reprehender.
	    				</div>
	    				<div class="testimonial-autor">
	    					<div class="img-box">
	    						<figure><img src="static/images/testimonial/2.png" alt=""></figure>
	    					</div>
	    					<div class="autor-content">
	    						<h4>Julia Robertson</h4>
	    						<span>Happy Client</span>
	    					</div>
	    				</div>
	    			</div>
    			</div>
    			
    			<div class="col-md-4 col-sm-6 col-xs-12">
    				<div class="single-item">
	    				<div class="text">
	    					Lorem ipsum dolor amet consectetur adipisicing elit sed eiusm tempor incididunt ut labore dolor magna aliqua enim ad minim veniam quis nos
							trud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehender.
	    				</div>
	    				<div class="testimonial-autor">
	    					<div class="img-box">
	    						<figure><img src="static/images/testimonial/3.png" alt=""></figure>
	    					</div>
	    					<div class="autor-content">
	    						<h4>Julia Robertson</h4>
	    						<span>Happy Client</span>
	    					</div>
	    				</div>
	    			</div>
    			</div>
    			<div class="col-md-4 col-sm-6 col-xs-12">
    				<div class="single-item">
	    				<div class="text">
	    					Lorem ipsum dolor amet consectetur adipisicing elit sed eiusm tempor incididunt ut labore dolor magna aliqua enim ad minim veniam quis nos
							trud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehender.
	    				</div>
	    				<div class="testimonial-autor">
	    					<div class="img-box">
	    						<figure><img src="static/images/testimonial/4.png" alt=""></figure>
	    					</div>
	    					<div class="autor-content">
	    						<h4>Julia Robertson</h4>
	    						<span>Happy Client</span>
	    					</div>
	    				</div>
	    			</div>
    			</div>
    			<div class="col-md-4 col-sm-6 col-xs-12">
    				<div class="single-item">
	    				<div class="text">
	    					Lorem ipsum dolor amet consectetur adipisicing elit sed eiusm tempor incididunt ut labore dolor magna aliqua enim ad minim veniam quis nos
							trud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehender.
	    				</div>
	    				<div class="testimonial-autor">
	    					<div class="img-box">
	    						<figure><img src="static/images/testimonial/5.png" alt=""></figure>
	    					</div>
	    					<div class="autor-content">
	    						<h4>Julia Robertson</h4>
	    						<span>Happy Client</span>
	    					</div>
	    				</div>
	    			</div>
    			</div>
    			<div class="col-md-4 col-sm-6 col-xs-12">
    				<div class="single-item">
	    				<div class="text">
	    					Lorem ipsum dolor amet consectetur adipisicing elit sed eiusm tempor incididunt ut labore dolor magna aliqua enim ad minim veniam quis nos
							trud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehender.
	    				</div>
	    				<div class="testimonial-autor">
	    					<div class="img-box">
	    						<figure><img src="static/images/testimonial/6.png" alt=""></figure>
	    					</div>
	    					<div class="autor-content">
	    						<h4>Julia Robertson</h4>
	    						<span>Happy Client</span>
	    					</div>
	    				</div>
	    			</div>
    			</div>  -->
    			
    		</div>
    		</div>
    		 <div class="qwe">
                    <%
                    Pager pager=(Pager)request.getAttribute("pager");
                    if(pager!=null){
                    	 int start= 1;
                         int end =pager.getPageCount();
                         if(pager.getPageCount()>5){
                        	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                        	 end=start+4;
                        	 if(end>pager.getPageCount()){
                        		 end=pager.getPageCount();
                        		 start=end-4;
                        	 }
                         }
                         %>
                         [<a class="ok" href="javascript:void(0)">上一页</a>]
                         <%
                    	for(int i=start;i<=end;i++){
                    		%>
                    		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}
                         %>
                         [<a class="no" href="javascript:void(0)">下一页</a>]
                         <%
                    }
                    %>
                    </div>
    	
    </section>
    <!-- testimonials section end -->

    <!-- subscribe section -->
    <section class="subscribe-section">
    <form id="myform" action="<%=path %>/commentServerlet?action=hotecomment" method="post">
    	<div class="container">
    		<div class="subscribe-title">
    			<div class="section-title">Subscribe to our Newsletter</div>
    		</div>
    		<div class="subscribe-form">
    			<input type="text" name="hotecomment" value="" placeholder="您对酒店的评论" required="">
    			<%
    				if(userinfo!=null){
    					
    			%>
    			<input type="hidden" name="userinfoid" value="<%=userinfo.getId()%>">
    			<% 
    				}
    			%>
    			<button type="button" id="but">提交评论</button>
    		</div>
    	</div>
    	</form>
    </section>
    <script >
    $(function(){
    	$("#but").click(function(){
    		
    		$.ajax({
    			url:"<%=path%>/commentServerlet",
    			data:{action:"pan"},
    			success:function(msg){
    				if(msg=="ok"){
    			
    			$("#myform").submit();		
    			<%-- location.href="<%=request.getContextPath()%>/CommentServlet?action=list" --%>
    				}
    				else{
    					alert("您还没有入住过此酒店")
    				
    				}
    			}
    		})
    		
    		
    	});
    
    })
    
    </script>
<!--

//-->
    <!-- subscribe section end -->

<jsp:include page="/inc/footer.jsp"/>
<style>
.qwe{
text-align:center;
}
</style>
<script>
$(function(){
	$(".no").click(function(){
		 $(".number").css("color","black");
		
		var cont=<%=pager.getPageNo()%>;
		if(cont<<%=pager.getPageCount()%>){
		cont++;
		}
		$(".number").each(function(){
			var id=$(this).html();
			if(id==cont){
				$(this).css("color","red");
			}
		})
		$.ajax({
			url:"<%=path%>/CommentServlet?action=initTwo",
				data:{id:cont},
					success:function(msg){
						$(".roww").html(msg);
					}
		})
	})
$(".ok").click(function(){
 $(".number").css("color","black");
var cont=<%=pager.getPageNo()%>;
if(cont>1){
cont--;
}
$(".number").each(function(){
	var id=$(this).html();
	if(id==cont){
		$(this).css("color","red");
	}
})
$.ajax({
url:"<%=path%>/CommentServlet?action=initTwo",
data:{id:cont},
success:function(msg){
	$(".roww").html(msg);
}
})
})
	$(".number").click(function(){
		 $(".number").css("color","black");
		$(this).css("color","red"); 
		var cont=$(this).html();
		$.ajax({
			url:"<%=path%>/CommentServlet?action=initTwo",
				data:{id:cont},
					success:function(msg){
						$(".roww").html(msg);
					}
		})
	})
})
</script>